<template>
  <el-dialog title="创建用户" :visible.sync="visible" @close="onClose">
    <el-form :model="formData" ref="form">

<!--      <el-form-item label="部门ID" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.deptId" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

      <el-form-item label="用户账号" :label-width="formLabelWidth" required>
        <el-input v-model="formData.userName" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="用户昵称" :label-width="formLabelWidth" required>
        <el-input v-model="formData.nickName" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="用户类型" :label-width="formLabelWidth" >
        <el-input v-model="formData.userType" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="用户邮箱" :label-width="formLabelWidth" >
        <el-input v-model="formData.email" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="手机号码" :label-width="formLabelWidth" >
        <el-input v-model="formData.phonenumber" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="用户性别" :label-width="formLabelWidth" >
        <el-input v-model="formData.sex" autocomplete="off"></el-input>
      </el-form-item>

<!--      <el-form-item label="头像地址" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.avatar" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

      <el-form-item label="密码" :label-width="formLabelWidth" >
        <el-input v-model="formData.password" autocomplete="off"></el-input>
      </el-form-item>

<!--      <el-form-item label="帐号状态" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.status" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="删除标志" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.delFlag" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="最后登录IP" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.loginIp" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="最后登录时间" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.loginDate" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="创建者" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.createBy" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="创建时间" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.createTime" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="更新者" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.updateBy" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="更新时间" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.updateTime" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

      <el-form-item label="备注" :label-width="formLabelWidth" >
        <el-input v-model="formData.remark" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="QQ" :label-width="formLabelWidth" >
        <el-input v-model="formData.qq" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="微信" :label-width="formLabelWidth" >
        <el-input v-model="formData.wx" autocomplete="off"></el-input>
      </el-form-item>

<!--      <el-form-item label="身份证号" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.idCard" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="钉钉ID" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.dingId" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="钉钉UnionId" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.dingUnionId" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="微信OpenId" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.wxOpenId" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

<!--      <el-form-item label="微信UnionId" :label-width="formLabelWidth" >-->
<!--        <el-input v-model="formData.wxUnionId" autocomplete="off"></el-input>-->
<!--      </el-form-item>-->

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="onClose">取 消</el-button>
      <el-button type="primary" @click="onSubmit">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {createSysUser} from "@/api/sys/user";
export default {
  name: 'SysUserCreate',
  props: {
    visible: false, 
  },
  data() {
    return {
      formData: {
        userId: '',

        deptId: '',

        userName: '',

        nickName: '',

        userType: '',

        email: '',

        phonenumber: '',

        sex: '',

        avatar: '',

        password: '',

        status: '',

        delFlag: '',

        loginIp: '',

        loginDate: '',

        createBy: '',

        createTime: '',

        updateBy: '',

        updateTime: '',

        remark: '',

        qq: '',

        wx: '',

        idCard: '',

        dingId: '',

        dingUnionId: '',

        wxOpenId: '',

        wxUnionId: '',

      },
      formLabelWidth: '120px'
    };
  },
  methods: {
    onClose() {
      this.$emit('update:visible', false)
    },
    onSubmit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          // 执行表单提交操作
          // this.formData 包含了通过校验的表单数据
          createSysUser(this.formData).then(res => {
            console.log('createSysUser - success');
            this.$emit('submit-success');
            this.onClose();
          });
        } else {
          console.log('Form validation failed');
        }
      });
    }
  }
}
</script>

<style scoped>
</style>
